﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

//////////////////////////////////////////////////////////////////////////
//StoredProcedures.cs                                                   //
//Last Edited: 4 Feb 2013 AdviseUP Mark II                              //
//First Edited: 31 Oct 2012 Mark II                                     //
//This file contains functions to simplify calling stored procedures    //
//////////////////////////////////////////////////////////////////////////
public class StoredProcedures
{
    //Constants which signify whether a stored procedure which returns an integer value was successful or not
    public const int SUCCESS = 1;
    public const int FAILURE = 0;

    /// <summary>
    /// Not used - all methods of this class are static
    /// </summary>
    public StoredProcedures()
    {
    }


    /// <summary>
    /// purgeAdvisorsAdviseesTranscripts()
    /// 
    /// Removes all advisee transcripts that an advisor has requested from the internal DB
    /// </summary>
    /// <param name="advisorID">The ID of the advisor whose requested transcript should be removed</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int purgeAdvisorsAdviseesTranscripts(String advisorID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@advisorID", advisorID);
        return SharedFunctions.runScalarStoredProcedure("purgeAdvisorsAdviseesTranscripts", parametersAndValues);
    } // end purgeAdvisorsAdviseesTranscripts()


    /// <summary>
    /// fetchAdviseeTranscript()
    /// 
    /// Inserts advisee's transcript data from view of banner data into internal
    /// DB Transcript table
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="requestID">The ID of the advisee/advisor who is looking at the transcript</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int fetchAdviseeTranscript(String adviseeID, String requestID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@requestID", requestID);
        return SharedFunctions.runScalarStoredProcedure("fetchAdviseeTranscript", parametersAndValues);
    } // end fetchAdviseeTranscript()


    /// <summary>
    /// purgeAdviseeTranscript()
    /// 
    /// Removes an the advisee's transcript data from internal database
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee whose transcript should be removed</param>
    /// <param name="requestID">The ID of the advisee/advisor who was viewing the transcript</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int purgeAdviseeTranscript(String adviseeID, String requestID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@requestID", requestID);
        return SharedFunctions.runScalarStoredProcedure("purgeAdviseeTranscript", parametersAndValues);
    } // end purgeAdviseeTranscript()


    /// <summary>
    /// mergeCourses()
    /// 
    /// Every Course in view of Banner data is either inserted into internal DB if it
    /// isn't already there or its info is updated 
    /// </summary>
    /// <returns>Returns an int >= 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int mergeCourses()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runScalarStoredProcedure("mergeCourses", parametersAndValues);
    } // end mergeCourses()

    /// <summary>
    /// mergePrereqs()
    /// 
    /// Every Prerequisite in view of Banner data is either inserted into internal DB if it
    /// isn't already there or its info is updated 
    /// </summary>
    /// <returns>Returns an int >= 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int mergePrereqs()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runScalarStoredProcedure("mergePrereqs", parametersAndValues);
    } // end mergePrereqs()

    /// <summary>
    /// mergeCoreqs()
    /// 
    /// Every Coreq in view of Banner data is either inserted into internal DB if it
    /// isn't already there or its info is updated 
    /// </summary>
    /// <returns>Returns an int >= 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int mergeCoreqs()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runScalarStoredProcedure("mergeCoreqs", parametersAndValues);
    } // end mergeCoreqs()

    /// <summary>
    /// updateElectiveTermInTemplate()
    /// 
    /// Updates the term for the selected elective in the Advisee's schedule that has
    /// the courseID as the selected course
    /// </summary>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveTermInTemplate(String templateID, String electiveID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveTermInTemplate", parametersAndValues);
    } // end updateElectiveTermInTemplate()

    /// <summary>
    /// updateElectiveTermInSchedule()
    /// 
    /// Updates the term for the selected elective in the Advisee's schedule that has
    /// the courseID as the selected course
    /// </summary>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveTermInSchedule(String adviseeID, String electiveID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveTermInSchedule", parametersAndValues);
    } // end updateElectiveTermInSchedule()

    /// <summary>
    /// updateElectiveSelectedCourseInTemplate()
    /// 
    /// Updates the selectedCourseID for the elective in the specified template that had
    /// the previousCourseID as the selected course
    /// </summary>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveSelectedCourseInTemplate(String templateID, String electiveID, String previousCourseID, String selectedCourseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@previousCourseID", previousCourseID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveSelectedCourseInTemplate", parametersAndValues);
    } // end updateElectiveSelectedCourseInTemplate()

    /// <summary>
    /// updateElectiveSelectedCourseInSchedule()
    /// 
    /// Updates the selectedCourseID for the elective in the Advisee's schedule that had
    /// the previousCourseID as the selected course
    /// </summary>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveSelectedCourseInSchedule(String adviseeID, String electiveID, String previousCourseID, String selectedCourseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@previousCourseID", previousCourseID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveSelectedCourseInSchedule", parametersAndValues);
    } // end updateElectiveSelectedCourseInSchedule()

    /// <summary>
    /// mergeEmployees()
    /// 
    /// Every Employee in view of Banner data is either inserted into internal DB if they
    /// aren't already there, or if they are their info is updated
    /// </summary>
    /// <returns>Returns an int >= 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int mergeEmployees()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runScalarStoredProcedure("mergeEmployees", parametersAndValues);
    } // end mergeEmployees()



    /// <summary>
    /// mergeAdvisees()
    /// 
    /// Every advisee in view of Banner data is either inserted into internal DB if they
    /// aren't already there, or if they are their info is updated
    /// </summary>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int mergeAdvisees()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runScalarStoredProcedure("mergeAdvisees", parametersAndValues);
    } // end mergeAdvisees()



    /// <summary>
    /// removeFormerAdvisor()
    /// 
    /// Removes the specified former advisor from the internal database
    /// </summary>
    /// <param name="employeeID">The email of the advisor to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeFormerAdvisor(String employeeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@employeeID", employeeID);
        return SharedFunctions.runScalarStoredProcedure("removeFormerAdvisor", parametersAndValues);
    } // end removeFormerAdvisor()


    /// <summary>
    /// getFormerElectives()
    /// 
    /// Gets a list of all the electives in the database not in any template or schedule
    /// </summary>
    /// <returns>A list of result rows (A list of dictionaries) with keys "electiveID" and "name" 
    /// or null if there was no result row</returns>
    public static List<Dictionary<String, Object>> getFormerElectives()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getFormerElectives", parametersAndValues);
    } // end getFormerElectives()

    /// <summary>
    /// getFormerAdvisors()
    /// 
    /// Gets a list of all the advisors in the database not in the view of advisors
    /// </summary>
    /// <returns>A list of result rows (A list of dictionaries) with keys "firstName", "lastName", "email", "location", 
    /// "phone", "isAdministrator", "employeeID" or null if there was no result row</returns>
    public static List<Dictionary<String, Object>> getFormerAdvisors()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getFormerAdvisors", parametersAndValues);
    } // end getFormerAdvisors()


    /// <summary>
    /// fetchAdvisor()
    /// 
    /// Inserts info for an Advisor into Employee table from view of banner data
    /// </summary>
    /// <param name="email">The email of the advisor to retrieve</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int fetchAdvisor(String email)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@email", email);
        return SharedFunctions.runScalarStoredProcedure("fetchAdvisor", parametersAndValues);
    } // end fetchAdvisor()


    /// <summary>
    /// fetchAdvisee()
    /// 
    /// Inserts info for an advisee into Advisee table from view of banner data
    /// </summary>
    /// <param name="email">The email of the advisee to retrieve</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int fetchAdvisee(String email)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@email", email);
        return SharedFunctions.runScalarStoredProcedure("fetchAdvisee", parametersAndValues);
    } // end fetchAdvisee()



    /// <summary>
    /// getElectiveName()
    /// 
    /// gets the electiveID and Name of the specified elective
    /// </summary>
    /// <param name="electiveID">The electiveID of the elective</param>
    /// <returns>Returns a result row (dictionary) with keys "electiveID" and "name" </returns>
    public static Dictionary<String, Object> getElectiveName(String electiveID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getElectiveName", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["electiveID"] = i["electiveID"];
            returnedRow["name"] = i["name"];
        }
        return returnedRow;
    }//end getElectiveName()

    /// <summary>
    /// removeElectiveFromTemplate()
    /// 
    /// Removes an elective from a template
    /// </summary>
    /// <param name="templateID">The ID of the template that we're removing the elective from</param>
    /// <param name="electiveID">The ID of the elective to remove</param>
    /// <param name="selectedCourseID">The ID of the selected course in the elective</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeElectiveFromTemplate(String templateID, String electiveID, String selectedCourseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        return SharedFunctions.runScalarStoredProcedure("removeElectiveFromTemplate", parametersAndValues);
    }// end removeElectiveFromTemplate()

    /// <summary>
    /// removeElectiveFromSchedule()
    /// 
    /// Removes an elective from an Advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee whose schedule we're removing the elective from</param>
    /// <param name="electiveID">The ID of the elective to remove</param>
    /// <param name="selectedCourseID">The ID of the selected course in the elective</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeElectiveFromSchedule(String adviseeID, String electiveID, String selectedCourseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        return SharedFunctions.runScalarStoredProcedure("removeElectiveFromSchedule", parametersAndValues);
    }// end removeElectiveFromSchedule()

    /// <summary>
    /// getCoursePrerequisites()
    /// 
    /// Gets a list of the prerequisite info for a given course 
    /// </summary>
    /// <param name="courseID">The courseID of the course</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "courseID", "dpt", "preReqLow", "preReqHigh", "preReqSet", and "preReqSubset"</returns>
    public static List<Dictionary<String, Object>> getCoursePrerequisites(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runStoredProcedure("getCoursePrerequisitesTest", parametersAndValues);
        //return SharedFunctions.runStoredProcedure("getCoursePrerequisites", parametersAndValues);
    } // end getCoursePrerequisites()

    /// <summary>
    /// getAdviseeTranscript()
    /// 
    /// Gets a list of the courses and grades from the view of Banner data for a given advisee
    /// </summary>
    /// <param name="adviseeID">The adviseeID of the advisee</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "courseID", "term", and "grade"</returns>
    public static List<Dictionary<String, Object>> getAdviseeTranscript(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runStoredProcedure("getAdviseeTranscript", parametersAndValues);
    } // end getAdviseeTranscript()

    /// <summary>
    /// uninitializeAdvisee()
    /// 
    /// removes all courses and electives from an advisee's schedule so they are
    /// uninitialized
    /// </summary>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise </returns>
    public static int uninitializeAdvisee(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        if (SharedFunctions.runScalarStoredProcedure("uninitializeAdvisee", parametersAndValues) > 0)
        {
            return SUCCESS;
        }
        else
        {
            return FAILURE;
        }
         
    }//end uninitializeAdvisee()

    /// <summary>
    /// demoteFromAdmin()
    /// 
    /// sets the isAdministrator bit of the specified employee to 0
    /// signifying that they aren't an administrator
    /// </summary>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise </returns>
    public static int demoteFromAdmin(String employeeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@employeeID", employeeID);
        return SharedFunctions.runScalarStoredProcedure("demoteFromAdmin", parametersAndValues);
    }//end demoteFromAdmin()

    /// <summary>
    /// promoteToAdmin()
    /// 
    /// Sets the Employee to be an Administrator
    /// </summary>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise </returns>
    public static int promoteToAdmin(String employeeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@employeeID", employeeID);
        return SharedFunctions.runScalarStoredProcedure("promoteToAdmin", parametersAndValues);
    }//end promoteToAdmin()
   


    /// <summary>
    /// initializedElectives()
    /// 
    /// checks if the advisee has any electives in their schedule
    /// </summary>
    /// <returns>Returns a result row (dictionary) with key "count" </returns>
    public static Dictionary<String, Object> initializedElectives(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("initializedElectives", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["count"] = i["count"];
        }
        return returnedRow;
    }//end initializedElectives()

    /// <summary>
    /// initializedCourses()
    /// 
    /// checks if the advisee has any courses in their schedule
    /// </summary>
    /// <returns>Returns a result row (dictionary) with key "count" </returns>
    public static Dictionary<String, Object> initializedCourses(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("initializedCourses", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["count"] = i["count"];
        }
        return returnedRow;
    }//end initializedCourses()

    /// <summary>
    /// getListOfElectives()
    /// 
    /// get a list of the electives in the database
    /// </summary>
    /// <returns>Returns a list of result rows (a list of dictionaries) with keys "electiveID" and "name"</returns>
    public static List<Dictionary<String, Object>> getListOfElectives()
    {

        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getListOfElectives", parametersAndValues);
    }//end getListOfElectives()


    /// <summary>
    /// getCoursePrediction()
    /// 
    /// Gets the # of students planning on taking a course in a given term
    /// </summary>
    /// <param name="courseID">The ID of the  course</param>
    /// <param name="term">The term to check</param>
    /// <returns>A result row with count? = # of students with that course & term in their schedule</returns>
    public static Dictionary<String, Object> getCoursePrediction(String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getCoursePrediction", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["count"] = i["count"];
        }
        return returnedRow;
    }//end getCoursePrediction()

     
        

    /// <summary>
    /// getElectivePrediction()
    /// 
    /// Gets the # of students planning on taking a given elective in a given term
    /// </summary>
    /// <param name="courseID">The ID of the  course</param>
    /// <param name="term">The term to check</param>
    /// <returns>A result which contains the # of students w/ that elective in the given term in the "count"</returns>
    public static Dictionary<String, Object> getElectivePrediction(String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getElectivePrediction", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["count"] = i["count"];
        }
        return returnedRow;
    }

    
    /// <summary>
    /// addCoReq()
    /// 
    /// Adds a corequisite to the database
    /// </summary>
    /// <param name="coReqID">The ID of the corequisite course</param>
    /// <param name="courseID">The ID of the course which requires the corequisite</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addCoreq(String coReqID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@coReqID", coReqID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("addCoreq", parametersAndValues);
    } // end addCoReq()

    /// <summary>
    /// setAdviseeStartDate()
    /// 
    /// Sets an advisees start date in the database
    /// </summary>
    /// <param name="startTerm">The term code (ex: 200901 for Fall 2008) to put in the database</param>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int setAdviseeStartDate(String startTerm, String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@startTerm", startTerm);
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runScalarStoredProcedure("setAdviseeStartDate", parametersAndValues);
    } // end setAdviseeStartDate()

    /// <summary>
    /// addCourse()
    /// 
    /// Adds a course to the database
    /// </summary>
    /// <param name="dpt">The department acronym of the course</param>
    /// <param name="num">The number of the course</param>
    /// <param name="name">The name of the course</param>
    /// <param name="credits">The number of credits for the course</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addCourse(String dpt, String num, String name, Double credits)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@dpt", dpt);
        parametersAndValues.Add("@num", num);
        parametersAndValues.Add("@name", name);
        parametersAndValues.Add("@credits", credits);
        return SharedFunctions.runScalarStoredProcedure("addCourse", parametersAndValues);
    } // end addCourse()

    /// <summary>
    /// addCourseToElective()
    /// 
    /// Adds a course to the possible choices of an elective
    /// </summary>
    /// <param name="electiveID"> the ID of the elective</param>
    /// <param name="courseID">The ID of the course to add</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addCourseToElective(String electiveID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("addCourseToElective", parametersAndValues);
    } // end addCourseToElective()

    /// <summary>
    /// addLogEntry()
    /// 
    /// Adds a log entry to the database for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="author">The author of a change (displayed in the log)</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addLogEntry(String adviseeID, String author)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@author", author);
        return SharedFunctions.runScalarStoredProcedure("addLogEntry", parametersAndValues);
    } // end addLogEntry()

    /// <summary>
    /// addNote()
    /// 
    /// Adds a note for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="note">The note to add</param>
    /// <param name="author">The author of the note</param>
    /// <param name="passphrase">The passphrase to encrypt the note with</param>
    public static int addNote(String adviseeID, String note, String author, String passphrase)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@note", note);
        parametersAndValues.Add("@author", author);
        parametersAndValues.Add("@passphrase", passphrase);
        return SharedFunctions.runScalarStoredProcedure("addNote", parametersAndValues);
    } // end addNote()

    /// <summary>
    /// addPreReq()
    /// 
    /// Adds a prerequisite to the database for a course
    /// </summary>
    /// <param name="preReqID">The ID of the prerequisite course</param>
    /// <param name="courseID">The ID of the course which requires the prerequisite</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addPrereq(String preReqID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@preReqID", preReqID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("addPrereq", parametersAndValues);
    } // end addPrereq()

    /// <summary>
    /// addTag()
    /// 
    /// Adds a tag to the database for a course
    /// </summary>
    /// <param name="courseID">The ID of the course</param>
    /// <param name="tag">The tag to add (1 = fall, 2 = spring, 3 = summer)</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int addTag(String courseID, String tag)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@tag", tag);
        return SharedFunctions.runScalarStoredProcedure("addTag", parametersAndValues);
    } // end addTag()

    /// <summary>
    /// changeTemplateName()
    /// 
    /// Changes an existing template's name
    /// </summary>
    /// <param name="name">The new name of the template</param>
    /// <param name="templateID">The ID of the template to change</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int changeTemplateName(String name, String templateID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@name", name);
        parametersAndValues.Add("@templateID", templateID);
        return SharedFunctions.runScalarStoredProcedure("changeTemplateName", parametersAndValues);
    } // end changeTemplateName()

    /// <summary>
    /// deleteCourse()
    /// 
    /// deletes a course from the database
    /// </summary>
    /// <param name="courseID">The ID of the course</param>
    /// <returns>Returns 1 if the procedure executes properly; 0 otherwise</returns>
    public static int deleteCourse(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("deleteCourse", parametersAndValues);
    } // end deleteCourse()

    /// <summary>
    /// getAdviseeName()
    /// 
    /// Gets the first name and last name of an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A result row (dictionary) with keys "firstName" and "lastName", or null if there was no result row</returns>
    public static Dictionary<String, Object> getAdviseeName(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdviseeName", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String,Object>();
            //select firstName, lastName
            returnedRow["firstName"] = i["firstName"];
            returnedRow["lastName"] = i["lastName"];
        }
        return returnedRow;
    } // end getAdviseeName()

    /// <summary>
    /// getAdvisees()
    /// 
    /// Returns a list of advisees for an employee
    /// </summary>
    /// <param name="employeeID">The ID of the employee</param>
    /// <returns>A list of result rows (list of dictionaries) with keys "adviseeID", "firstName", and "lastName"</returns>
    public static List<Dictionary<String, Object>> getAdvisees(String employeeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@employeeID", employeeID);
        return SharedFunctions.runStoredProcedure("getAdvisees", parametersAndValues);
    } // end getAdvisees()

    /// <summary>
    /// getAdviseeStartTerm()
    /// 
    /// gets the start term of an employee in termcode format (example: 200901 = Fall 2008)
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A result row (dictionary) with key "startTerm", or null if there was no result row</returns>
    public static Dictionary<String, Object> getAdviseeStartTerm(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdviseeStartTerm", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["startTerm"] = i["startTerm"];
        }
        return returnedRow;
    } // end getAdviseeStartTerm()

    /// <summary>
    /// getAdvisor()
    /// 
    /// Gets advisor information for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A result row (dictionary) with keys "firstName", "lastName", "email", "location", "phone", and "isAdministrator" or null if there was no result row</returns>
    public static Dictionary<String, Object> getAdvisor(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdvisor", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["firstName"] = i["firstName"];
            returnedRow["lastName"] = i["lastName"];
            returnedRow["email"] = i["email"];
            returnedRow["location"] = i["location"];
            returnedRow["phone"] = i["phone"];
            returnedRow["isAdministrator"] = i["isAdministrator"];
        }
        return returnedRow;
    } // end getAdvisor()

    /// <summary>
    /// getMultipleAdvisors()
    /// 
    /// Gets information about all advisors an advisee has
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A list of result rows (dictionary) with keys "firstName", "lastName", "email", "location", "phone", and "isAdministrator" or null if there was no result row</returns>
    public static List<Dictionary<String, Object>> getMultipleAdvisors(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdvisor", parametersAndValues);

        //Test Case
        //Dummy Advisor to test if it shows multiple
        //Dictionary<String, Object> dummy = new Dictionary<String, Object>();
        //    dummy["firstName"] = "Hello";
        //    dummy["lastName"] = "World";
        //    dummy["email"] = "example@up.edu";
        //    dummy["location"] = "SHI 034";
        //    dummy["phone"] = "(xxx)xxx-xxxx";
        //    dummy["isAdministrator"] = "No";
        //    results.Add(dummy);

        return results;
    } // end getAdvisor()

    /// <summary>
    /// getAllAdvisors()
    /// 
    /// Gets a list of all the advisors in the database
    /// </summary>
    /// <returns>A list of result rows (A list of dictionaries) with keys "firstName", "lastName", "email",
    /// "location", "phone", "isAdministrator", and "employeeID" or null if there was no result row</returns>
    public static List<Dictionary<String, Object>> getAllAdvisors()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getAllAdvisors", parametersAndValues);
    } // end getAllAdvisors()

    /// <summary>
    /// getAllAdvisees()
    /// 
    /// returns a list of all the advisees in the database
    /// </summary>
    /// <returns>A list of result rows (a list of dictionaries) with keys "adviseeID", "firstName", and "lastName"</returns>
    public static List<Dictionary<String, Object>> getAllAdvisees()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getAllAdvisees", parametersAndValues);
    } // end getAllAdvisees()

    /// <summary>
    /// getAdvisorByEmail()
    /// 
    /// Gets an advisor from the database by referencing their email
    /// </summary>
    /// <returns>A result row (A dictionary) with keys "firstName", "lastName", "email", "location", "phone", and "isAdministrator" or null if there was no result row</returns>
    public static Dictionary<String,Object> getAdvisorByEmail(String email)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@email", email);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdvisorByEmail", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["firstName"] = i["firstName"];
            returnedRow["lastName"] = i["lastName"];
            returnedRow["email"] = i["email"];
            returnedRow["location"] = i["location"];
            returnedRow["phone"] = i["phone"];
            returnedRow["isAdministrator"] = i["isAdministrator"];
        }
        return returnedRow;
    } // end getAdvisorByEmail()

    /// <summary>
    /// getAdviseeByEmail()
    /// 
    /// Gets an advisee from the database by referencing their email
    /// </summary>
    /// <returns>A result row (A dictionary) with keys "firstName", "lastName", and "adviseeID" or null if there was no result row</returns>
    public static Dictionary<String, Object> getAdviseeByEmail(String email)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@email", email);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getAdviseeByEmail", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["firstName"] = i["firstName"];
            returnedRow["lastName"] = i["lastName"];
            returnedRow["adviseeID"] = i["adviseeID"];
        }
        return returnedRow;
    } // end getAdviseeByEmail()

   
    /// <summary>
    /// getCourse()
    /// 
    /// Gets course information for a specific course
    /// </summary>
    /// <param name="courseID">The ID of the course to get info for</param>
    /// <returns>A result row (a dictionary) with keys "courseID", "dpt", "num", "name" and "credits", or null if there was no result row</returns>
    public static Dictionary<String, Object> getCourse(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getCourse", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["courseID"] = i["courseID"];
            returnedRow["dpt"] = i["dpt"];
            returnedRow["num"] = i["num"];
            returnedRow["name"] = i["name"];
            returnedRow["credits"] = i["credits"];
        }
        return returnedRow;
    } // end getCourse()

    /// <summary>
    /// getCourseCoeqs()
    /// 
    /// Gets a list of the corequisite courses for a given course
    /// </summary>
    /// <param name="courseID">The course ID of the course</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "courseID", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getCourseCoreqs(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runStoredProcedure("getCourseCorequisitesTest", parametersAndValues);
        //return SharedFunctions.runStoredProcedure("getCourseCoreqs", parametersAndValues);
    } // end getCourseCoreqs()

    /// <summary>
    /// getCoursePrereqs()
    /// 
    /// Gets a list of the prerequisite courses for a given course
    /// </summary>
    /// <param name="courseID">The course ID of the course</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "courseID", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getCoursePrereqs(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runStoredProcedure("getCoursePrereqs", parametersAndValues);
    } // end getCoursePrereqs()

    /// <summary>
    /// getCourseTags()
    /// 
    /// Gets a list of tags for a given course
    /// </summary>
    /// <param name="courseID">The course ID of the course</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "tag"</returns>
    public static List<Dictionary<String, Object>> getCourseTags(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runStoredProcedure("getCourseTags", parametersAndValues);
    } // end getCourseTags()

    /// <summary>
    /// getElectiveChoices()
    /// 
    /// Gets the list of courses choices available for an elective
    /// </summary>
    /// <param name="electiveID">The ID of the elective</param>
    /// <returns>Returns a list of result rows (a list of dictionaries) with keys "courseID", "dpt", "num", "name" and "credits"</returns>
    public static List<Dictionary<String, Object>> getElectiveChoices(String electiveID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        return SharedFunctions.runStoredProcedure("getElectiveChoices", parametersAndValues);
    } // end getElectiveChoices()

    /// <summary>
    /// getEmployeeName()
    /// 
    /// gets the first and last name of an employee
    /// </summary>
    /// <param name="employeeID">The ID of the employee</param>
    /// <returns>A result row (dictionary) with keys "firstName" and "lastName", or null if there was no result row</returns>
    public static Dictionary<String, Object> getEmployeeName(String employeeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@employeeID", employeeID);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getEmployeeName", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["firstName"] = i["firstName"];
            returnedRow["lastName"] = i["lastName"];
        }
        return returnedRow;
    } // end getEmployeeName()

    /// <summary>
    /// getLastCourseID()
    /// 
    /// get the ID of the last course which was modified/added in the database
    /// </summary>
    /// <returns>Returns the ID of the last modified/added course in the database or a negative number if there was an error</returns>
    public static int getLastCourseID()
    {
        return SharedFunctions.getLastCourseID();
    } // end getLastCourseID()

    /// <summary>
    /// getLastElectiveID()
    /// 
    /// get the ID of the last elective which was modified/added in the database
    /// </summary>
    /// <returns>Returns the ID of the last modified/added elective in the database or a negative number if there was an error</returns>
    public static int getLastElectiveID()
    {
        return SharedFunctions.getLastElectiveID();
    } // end getLastElectiveID()

    /// <summary>
    /// getLastTemplateID()
    /// 
    /// get the ID of the last modified/added template in the database
    /// </summary>
    /// <returns>Returns the ID of the last modified/added template in the database or a negative number if there was an error</returns>
    public static int getLastTemplateID()
    {
        return SharedFunctions.getLastTemplateID();
    } // end getLastTemplateID()

    /// <summary>
    /// getListOfCourses()
    /// 
    /// get a list of the courses in the database
    /// </summary>
    /// <returns>Returns a list of result rows (a list of dictionaries) with keys "courseID", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getListOfCourses()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getListOfCourses", parametersAndValues);
    } // end getListOfCourses()

    /// <summary>
    /// getListOfCoursesFiltered()
    /// 
    /// get a list of the courses in the database which match the passed dpt acronym
    /// </summary>
    /// <param name="dpt">The acronym of the department to filter on</param>
    /// <returns>Returns a list of result rows (a list of dictionaries) with keys "courseID", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getListOfCoursesFiltered(String dpt)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@dpt", dpt);
        return SharedFunctions.runStoredProcedure("getListOfCoursesFiltered", parametersAndValues);
    } // end getListOfCoursesFiltered()

    /// <summary>
    /// getLogEntries()
    /// 
    /// Gets a list of the log entries for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "logEntryID", "author", and "date"</returns>
    public static List<Dictionary<String, Object>> getLogEntries(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runStoredProcedure("getLogEntries", parametersAndValues);
    } // end getLogEntries()

    /// <summary>
    /// getNotes()
    /// 
    /// Gets a list of the notes for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="passphrase">The passphrase used to decrypt the note</param>
    /// <returns>A list of result rows (A list of dictionaries) with keys "noteID", "note", "date", and "author"</returns>
    public static List<Dictionary<String, Object>> getNotes(String adviseeID, String passphrase)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@passphrase", passphrase);
        return SharedFunctions.runStoredProcedure("getNotes", parametersAndValues);
    } // end getNotes()

    /// <summary>
    /// getScheduleCourseInfo()
    /// 
    /// gets all the courses in an advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A list of result rows (a list of dictionaries) with keys "courseID", "dpt", "num",  "name", "credits" and "term"</returns>
    public static List<Dictionary<String, Object>> getScheduleCourseInfo(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runStoredProcedure("getScheduleCourseInfo", parametersAndValues);
    } // end getScheduleCourseInfo()

    /// <summary>
    /// getScheduleElectiveInfo()
    /// 
    /// Gets all the electives in an advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <returns>A list of result rows (a list of dictionaries) with keys "electiveID", "electiveName", "selectedCourseID", "term", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getScheduleElectiveInfo(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runStoredProcedure("getScheduleElectiveInfo", parametersAndValues);
    } // end getScheduleElectiveInfo()

    /// <summary>
    /// getSingleNote()
    /// 
    /// Gets a single note from the database
    /// </summary>
    /// <param name="noteID">The ID of the note</param>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="passphrase">The passphrase used to decrypt the note</param>
    /// <returns>A result row (a dictionary) with key "note", or null if there was no result row</returns>
    public static Dictionary<String, Object> getSingleNote(String noteID, String adviseeID, String passphrase)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@noteID", noteID);
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@passphrase", passphrase);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getSingleNote", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach (Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["note"] = i["note"];
        }
        return returnedRow;
    } // end getSingleNote()

    /// <summary>
    /// getTemplateCourseInfo()
    /// 
    /// Get all the courses in a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <returns>Returns a list of result rows (A list of dictionaries) with keys "courseID", "dpt", "num", "name", "credits", and "term"</returns>
    public static List<Dictionary<String, Object>> getTemplateCourseInfo(String templateID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        return SharedFunctions.runStoredProcedure("getTemplateCourseInfo", parametersAndValues);
    } // end getTemplateCourseInfo()

    /// <summary>
    /// getTemplateElectiveInfo()
    /// 
    /// Gets all the electives in a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <returns>Returns a list of result rows (A list of dictionaries) with keys "electiveID", "electiveName", "selectedCourseID", "term", "dpt", "num", "name", and "credits"</returns>
    public static List<Dictionary<String, Object>> getTemplateElectiveInfo(String templateID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        return SharedFunctions.runStoredProcedure("getTemplateElectiveInfo", parametersAndValues);
    } // end getTemplateElectiveInfo()
    
    /// <summary>
    /// getTemplates()
    /// 
    /// get all the templates in the database
    /// </summary>
    /// <returns>Returns a list of result rows (A list of dictionaries) with keys "templateID", and "name"</returns>
    public static List<Dictionary<String, Object>> getTemplates()
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        return SharedFunctions.runStoredProcedure("getTemplates", parametersAndValues);
    } // end getTemplates()

    /// <summary>
    /// getTemplateName()
    /// 
    /// gets the name of a template
    /// </summary>
    /// <param name="id">The id of the template</param>
    /// <returns>Returns a result row (A dictionary) with key "name", or null if there was no result</returns>
    public static Dictionary<String, Object> getTemplateName(String id)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", id);
        List<Dictionary<String, Object>> results = SharedFunctions.runStoredProcedure("getTemplateName", parametersAndValues);
        Dictionary<String, Object> returnedRow = null;
        foreach(Dictionary<String, Object> i in results)
        {
            returnedRow = new Dictionary<String, Object>();
            returnedRow["name"] = i["name"];
        }
        return returnedRow;

    } // end getTemplateName()

    /// <summary>
    /// insertCourseIntoSchedule()
    /// 
    /// Inserts a course into an advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="courseID">The ID of the course</param>
    /// <param name="term">The position (termcode) of where the course should be placed in the schedule</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int insertCourseIntoSchedule(String adviseeID, String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("insertCourseIntoSchedule", parametersAndValues);
    } // end insertCourseIntoSchedule()

    /// <summary>
    /// insertCourseIntoTemplate()
    /// 
    /// inserts a course into a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <param name="courseID">The ID of the course</param>
    /// <param name="term">The position (termcode) of where the course should be placed in the template</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int insertCourseIntoTemplate(String templateID, String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("insertCourseIntoTemplate", parametersAndValues);
    } // end insertCourseIntoTemplate()

    /// <summary>
    /// insertElectiveIntoSchedule()
    /// 
    /// inserts an elective into an advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="electiveID">The ID of the elective</param>
    /// <param name="selectedCourseID">The ID of the selected course in the elective</param>
    /// <param name="term">The position (termcode) of where the course should be placed in the schedule</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int insertElectiveIntoSchedule(String adviseeID, String electiveID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("insertElectiveIntoSchedule", parametersAndValues);
    } // end insertElectiveIntoSchedule()

    /// <summary>
    /// insertElectiveIntoTemplate()
    /// 
    /// Inserts an elective into a template
    /// </summary>
    /// <param name="electiveID">The ID of the elective</param>
    /// <param name="templateID">The ID of the template</param>
    /// <param name="selectedCourseID">The selected course ID of the template</param>
    /// <param name="term">The termcode (ex: 200901 for Fall 2008) for where the elective should be placed in the template</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int insertElectiveIntoTemplate(String electiveID, String templateID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("insertElectiveIntoTemplate", parametersAndValues);
    } // end insertElectiveIntoTemplate()

    /// <summary>
    /// makeNewElective()
    /// 
    /// Make a new elective and add it to the database
    /// </summary>
    /// <param name="name">The name of the elective</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int makeNewElective(String name)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@name", name);
        return SharedFunctions.runScalarStoredProcedure("makeNewElective", parametersAndValues);
    } // end makeNewElective()

    /// <summary>
    /// makeNewTemplate()
    /// 
    /// Make a new template and add it to the database
    /// </summary>
    /// <param name="name">The name of the template</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int makeNewTemplate(String name)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@name", name);
        return SharedFunctions.runScalarStoredProcedure("makeNewTemplate", parametersAndValues);
    } // end makeNewTemplate()

    /// <summary>
    /// removeAdvisee()
    /// 
    /// Removes an advisee from the database
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeAdvisee(String adviseeID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        return SharedFunctions.runScalarStoredProcedure("removeAdvisee", parametersAndValues);
    } // end removeAdvisee()
    
    /// <summary>
    /// removeAllCoreqs()
    /// 
    /// Removes all corequisites from a given course
    /// </summary>
    /// <param name="courseID">The ID of the course to remove all corequisites from</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeAllCoreqs(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeAllCoreqs", parametersAndValues);
    } // end removeAllCoreqs()

    /// <summary>
    /// removeAllPrereqs()
    /// 
    /// Removes all prerequisites from a given course
    /// </summary>
    /// <param name="courseID">The ID of the course to remove all prerequisites from</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeAllPrereqs(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeAllPrereqs", parametersAndValues);
    } // end removeAllPrereqs()

    /// <summary>
    /// removeAllTags()
    /// 
    /// Removes all tags from a given course
    /// </summary>
    /// <param name="courseID">The ID of the course to remove all tags from</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeAllTags(String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeAllTags", parametersAndValues);
    } // end removeAllTags()

    /// <summary>
    /// removeAllcoreq()
    /// 
    /// Removes a corequisite from a course
    /// </summary>
    /// <param name="coReqID">The ID of the corequisite course to remove</param>
    /// <param name="courseID">The ID of the course which requires the corequisite</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeCoreq(String coReqID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@coReqID", courseID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeCoreq", parametersAndValues);
    } // end removeAllCoreq()

    /// <summary>
    /// removeCourseFromElective()
    /// 
    /// removes a course from the list of possible choices for an elective
    /// </summary>
    /// <param name="electiveID">The ID of the elective</param>
    /// <param name="courseID">The ID of the course to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeCourseFromElective(String electiveID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeCourseFromElective", parametersAndValues);
    } // end removeCourseFromElective()

    /// <summary>
    /// removeCourseFromSchedule()
    /// 
    /// removes a course from an advisee's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="courseID">The ID of the course to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeCourseFromSchedule(String adviseeID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeCourseFromSchedule", parametersAndValues);
    } // end removeCourseFromSchedule()

    /// <summary>
    /// removeCourseFromTemplate()
    /// 
    /// removes a course from a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <param name="courseID">The ID of the course to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeCourseFromTemplate(String templateID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removeCourseFromTemplate", parametersAndValues);
    } // end removeCourseFromTemplate()

    /// <summary>
    /// removeElective()
    /// 
    /// Removes an elective from the database
    /// </summary>
    /// <param name="electiveID">The ID of the elective to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeElective(String electiveID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        return SharedFunctions.runScalarStoredProcedure("removeElective", parametersAndValues);
    } // end removeElective()

    /// <summary>
    /// removeNote()
    /// 
    /// Removes a note from the database
    /// </summary>
    /// <param name="noteID">The ID of the note to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeNote(String noteID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@noteID", noteID);
        return SharedFunctions.runScalarStoredProcedure("removeNote", parametersAndValues);
    } // end removeNote()

    /// <summary>
    /// removeLogEntry()
    /// 
    /// Removes a log  entry from the database
    /// </summary>
    /// <param name="noteID">The ID of the log entry to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeLogEntry(String logEntryID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@logEntryID", logEntryID);
        return SharedFunctions.runScalarStoredProcedure("removeLogEntry", parametersAndValues);
    } // end removeNote()

    /// <summary>
    /// removePrereq()
    /// 
    /// Removes a prerequisite from a course
    /// </summary>
    /// <param name="preReqID">The ID of the prequisite course to remove</param>
    /// <param name="courseID">The ID of the course which requires the prequisite</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removePrereq(String preReqID, String courseID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@preReqID", preReqID);
        parametersAndValues.Add("@courseID", courseID);
        return SharedFunctions.runScalarStoredProcedure("removePrereq", parametersAndValues);
    } // end removePrereq()


    /// <summary>
    /// removeTag()
    /// 
    /// Removes a tag from a course
    /// </summary>
    /// <param name="courseID">The ID of the course to remove the tag from</param>
    /// <param name="tag">The tag to remove (1,2, or 3)</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeTag(String courseID, String tag)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@tag", tag);
        return SharedFunctions.runScalarStoredProcedure("removeTag", parametersAndValues);
    } // end removeTag()


    /// <summary>
    /// removeTemplate()
    /// 
    /// Removes a template from the database
    /// </summary>
    /// <param name="templateID">The ID of the template to remove</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int removeTemplate(String templateID)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        return SharedFunctions.runScalarStoredProcedure("removeTemplate", parametersAndValues);
    } // end removeTemplate()

    /// <summary>
    /// updateCourseInSchedule()
    /// 
    /// Changes the location of a course in a student's schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="courseID">The ID of the course to change</param>
    /// <param name="term">The new location of the course in the student's schedule in term code format</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateCourseInSchedule(String adviseeID, String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateCourseInSchedule", parametersAndValues);
    } // end updateCourseInSchedule()

    /// <summary>
    /// updateCourseInTemplate()
    /// 
    /// Changes the location of a course in a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <param name="courseID">The ID of the course to move</param>
    /// <param name="term">The new location of the course in the student's schedule in term code format</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateCourseInTemplate(String templateID, String courseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@courseID", courseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateCourseInTemplate", parametersAndValues);
    } // end updateCourseInTemplate()

    /// <summary>
    /// updateElectiveInSchedule()
    /// 
    /// Changes the location of an elective in a schedule
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="electiveID">The ID of the elective to move0</param>
    /// <param name="selectedCourseID">The ID of the selected course ID in the elective</param>
    /// <param name="term">The new location of the course in the student's schedule in term code format</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveInSchedule(String adviseeID, String electiveID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveInSchedule", parametersAndValues);
    } // end updateElectiveInSchedule()


    /// <summary>
    /// updateElectiveInTemplate()
    /// 
    /// Changes the location of an elective in a template
    /// </summary>
    /// <param name="templateID">The ID of the template</param>
    /// <param name="electiveID">The ID of the elective to move</param>
    /// <param name="selectedCourseID">The ID of the selected course in the Elective</param>
    /// <param name="term">The new location of the course in the student's schedule in term code format</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveInTemplate(String templateID, String electiveID, String selectedCourseID, String term)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@templateID", templateID);
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@selectedCourseID", selectedCourseID);
        parametersAndValues.Add("@term", term);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveInTemplate", parametersAndValues);
    } // end updateElectiveInTemplate()


    /// <summary>
    /// updateElectiveName()
    /// 
    /// Changes an existing elective's name
    /// </summary>
    /// <param name="electiveID">The ID of the elective</param>
    /// <param name="name">The new name of the elective</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateElectiveName(String electiveID, String name)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@electiveID", electiveID);
        parametersAndValues.Add("@name", name);
        return SharedFunctions.runScalarStoredProcedure("updateElectiveName", parametersAndValues);
    } // end updateElectiveName()


    /// <summary>
    /// updateNote()
    /// 
    /// Updates the contents of an existing note for an advisee
    /// </summary>
    /// <param name="adviseeID">The ID of the advisee</param>
    /// <param name="noteID">The ID of the note to change</param>
    /// <param name="note">The contents of the note</param>
    /// <param name="author">The author of the note</param>
    /// <param name="passphrase">The encryption key for the text of the note</param>
    /// <returns>Returns a 1 if the stored procedure executed properly, 0 otherwise</returns>
    public static int updateNote(String adviseeID, String noteID, String note, String author, String passphrase)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@adviseeID", adviseeID);
        parametersAndValues.Add("@noteID", noteID);
        parametersAndValues.Add("@note", note);
        parametersAndValues.Add("@author", author);
        parametersAndValues.Add("@passphrase", passphrase);
        return SharedFunctions.runScalarStoredProcedure("updateNote", parametersAndValues);
    } // end updateNote()

    /// <summary>
    /// usedTemplateName()
    /// 
    /// Determines if a template name is already in use
    /// </summary>
    /// <param name="name">The desired name of the template</param>
    /// <returns>???Returns a 1 if the template already exists???</returns>
    public static int usedTemplateName(String name)
    {
        Dictionary<String, Object> parametersAndValues = new Dictionary<String, Object>();
        parametersAndValues.Add("@name", name);
        return SharedFunctions.runScalarStoredProcedure("usedTemplateName", parametersAndValues);
    } // end usedTemplateName()
}